package com.liang.utils;

import cn.hutool.core.date.DateUtil;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @ClassName TimeUtils
 * @Description TODO
 * @Author liang
 * @Date 2019/4/9 23:20
 * @Version 1.0
 **/
public class TimeUtils {
   private static   SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd");

    public static Date stringToDate(String time) throws ParseException {
        sf.setLenient(false);
        Date date = sf.parse(time);
        return date;
    }
    public static String dateToString(Date date){
        String time = sf.format(date);
        return time;
    }
    public static String getToday(){
        String today= DateUtil.today();
        Date date = DateUtil.parse(today);
        String formatday = DateUtil.format(date, "yyyyMMdd");
        return formatday;
    }
    public static String fmtDate(String t){
        Date date = DateUtil.parse(t);
        String formatday = DateUtil.format(date, "yyyy/MM/dd");
        return formatday;
    }

    public static String fmToday(){
        Date date = DateUtil.parse(DateUtil.today());
        String formatday = DateUtil.format(date, "yyyy/MM/dd");
        return formatday;
    }

}
